import type { NormalizeProps, PropTypes } from "@zag-js/types"
import type { {{pascalCase machine}}Api, {{pascalCase machine}}Service } from "./{{dashCase machine}}.types"
import { parts } from "./{{dashCase machine}}.anatomy"
import * as dom from "./{{dashCase machine}}.dom"

export function connect<T extends PropTypes>(service: {{pascalCase machine}}Service, normalize: NormalizeProps<T>): {{pascalCase machine}}Api<T> {
  const { scope } = service

  return {
    getRootProps() {
      return normalize.element({
        ...parts.root.attrs,
        id: dom.getRootId(scope),
      })
    },
  }
}
